package jxau.jwgl.web.utils;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * BasePathInterceptor
 *
 * @author LongShu 2017/05/01
 */
public class BasePathInterceptor extends HandlerInterceptorAdapter {

    private String basePathKey = "base";// ${base}

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String contextPath = request.getContextPath();
        request.setAttribute(basePathKey, contextPath);
        return true;
    }

    public String getBasePathKey() {
        return basePathKey;
    }

    public void setBasePathKey(String basePathKey) {
        this.basePathKey = basePathKey;
    }

}
